Hệ thống quản lý phòng khám trực tuyến bằng PHP

1 <?php
2     $currDir = dirname(__FILE__);
3     require(
"{$currDir}/incCommon.php");
4     $GLOBALS[
'page_title'] = $Translation['members'];
5     include(
"{$currDir}/incHeader.php");
6
7     
// process search
8     
if($_GET['searchMembers'] != ""){
9         $searchSQL = makeSafe($_GET[
'searchMembers']);
10         $searchHTML = html_attr($_GET[
'searchMembers']);
11         $searchURL = urlencode($_GET[
'searchMembers']);
12         $searchField = intval($_GET[
'searchField']);
13         $searchFieldName = array_search($searchField, array(
14             
'm.memberID' => 1,
15             
'g.name' => 2,
16             
'm.email' => 3,
17             
'm.custom1' => 4,
18             
'm.custom2' => 5,
19             
'm.custom3' => 6,
20             
'm.custom4' => 7,
21             
'm.comments' => 8
22         ));
23         
if(!$searchFieldName){ // = search all fields
24             $
where = "where (m.memberID like '%{$searchSQL}%' or g.name like '%{$searchSQL}%' or m.email like '%{$searchSQL}%' or m.custom1 like '%{$searchSQL}%' or m.custom2 like '%{$searchSQL}%' or m.custom3 like '%{$searchSQL}%' or m.custom4 like '%{$searchSQL}%' or m.comments like '%{$searchSQL}%')";
25         }
else{ // = search a specific field
26             $
where = "where ({$searchFieldName} like '%{$searchSQL}%')";
27         }
28     }
else{
29         $searchSQL =
'';
30         $searchHTML =
'';
31         $searchField =
0;
32         $searchFieldName =
'';
33         $
where = '';
34     }
35
36     
// process groupID filter
37     $groupID = intval($_GET[
'groupID']);
38     
if($groupID){
39         
if($where != ''){
40             $
where .= " and (g.groupID='{$groupID}')";
41         }
else{
42             $
where = "where (g.groupID='{$groupID}')";
43         }
44     }
45
46     
// process status filter
47     $status = intval($_GET[
'status']); // 1=waiting approval, 2=active, 3=banned, 0=any
48     
if($status){
49         
switch($status){
50             
case 1:
51                 $statusCond =
"(m.isApproved=0)";
52                 
break;
53             
case 2:
54                 $statusCond =
"(m.isApproved=1 and m.isBanned=0)";
55                 
break;
56             
case 3:
57                 $statusCond =
"(m.isApproved=1 and m.isBanned=1)";
58                 
break;
59             
default:
60                 $statusCond =
"";
61         }
62         
if($where != '' && $statusCond != ''){
63             $
where .= " and {$statusCond}";
64         }
else{
65             $
where = "where {$statusCond}";
66         }
67     }
68
69     $numMembers = sqlValue(
"select count(1) from membership_users m left join membership_groups g on m.groupID=g.groupID {$where}");
70     
if(!$numMembers){
71         echo
"<div class=\"alert alert-warning\">{$Translation['no matching results found']}</div>";
72         $noResults =
true;
73         $page =
1;
74     }
else{
75         $noResults =
false;
76     }
77
78     $page = max(
1, intval($_GET['page']));
79     
if($page > ceil($numMembers / $adminConfig['membersPerPage']) && !$noResults){
80         redirect(
"admin/pageViewMembers.php?page=" . ceil($numMembers/$adminConfig['membersPerPage']));
81     }
82
83     $start = ($page -
1) * $adminConfig['membersPerPage'];
84
85 ?>
86 <div
class="page-header">
87     <h1>
88         <?php echo $Translation[
'members'] ; ?>
89         <div
class="pull-right">
90             <a href=
"pageEditMember.php" class="btn btn-success btn-lg"><i class="glyphicon glyphicon-plus"></i> <?php echo $Translation['add new member']; ?></a>
91         </div>
92     </h1>
93 </div>
94
95 <table
class="table table-striped table-bordered table-hover">
96     <thead>
97         <tr>
98             <th colspan=
"9" align="center">
99                 <form
class="form-inline" method="get" action="pageViewMembers.php">
100                     <input type=
"hidden" name="page" value="1">
101
102                     <div
class="form-group">
103                         <?php
104                             $originalValues = array (
'<SEARCH>','<HTMLSELECT>');
105                             $searchValue =
'<input class="form-control" type="text" name="searchMembers" value="' . $searchHTML . '">';
106                             $arrFields = array(
0, 1, 2, 3, 4, 5, 6, 7, 8);
107                             $arrFieldCaptions = array($Translation[
'all fields'], $Translation['username'], $Translation["group"], $Translation["email"], $adminConfig['custom1'], $adminConfig['custom2'], $adminConfig['custom3'], $adminConfig['custom4'], $Translation["comments"]);
108                             $htmlSelect = htmlSelect(
'searchField', $arrFields, $arrFieldCaptions, $searchField);
109                             $replaceValues = array($searchValue, $htmlSelect);
110                             echo str_replace($originalValues, $replaceValues, $Translation[
'search members']);
111                         ?>
112                     </div>
113
114                     <div
class="form-group">
115                         <label
for="groupID" class="control-label"><?php echo $Translation["group"]; ?></label>
116                         <?php echo htmlSQLSelect(
"groupID", "select groupID, name from membership_groups order by name", $groupID); ?>
117                     </div>
118
119                     <div
class="form-group">
120                         <label
for="" class="control-label"><?php echo $Translation["Status"]; ?></label>
121                         <?php
122                             $arrFields = array(
0, 1, 2, 3);
123                             $arrFieldCaptions = array($Translation[
'any'], $Translation['waiting approval'], $Translation['active'], $Translation['Banned']);
124                             echo htmlSelect(
"status", $arrFields, $arrFieldCaptions, $status);
125                         ?>
126                     </div>
127
128                     <div
class="form-group">
129                         <button
class="btn btn-primary" type="submit"><i class="glyphicon glyphicon-search"></i> <?php echo $Translation['find'] ; ?></button>
130                         <a
class="btn btn-warning" href="pageViewMembers.php"><i class="glyphicon glyphicon-remove"></i> <?php echo $Translation['reset'] ; ?></a>
131                     </div>
132                 </form>
133             </th>
134         </tr>
135
136         <tr>
137             <th><?php echo $Translation[
'username'] ; ?></th>
138             <th><?php echo $Translation[
"group"] ; ?></th>
139             <th><?php echo $Translation[
'sign up date'] ; ?></th>
140             <th><?php echo $adminConfig[
'custom1']; ?></th>
141             <th><?php echo $adminConfig[
'custom2']; ?></th>
142             <th><?php echo $adminConfig[
'custom3']; ?></th>
143             <th><?php echo $adminConfig[
'custom4']; ?></th>
144             <th><?php echo $Translation[
'Status'] ; ?></th>
145             <th>&nbsp;</th>
146         </tr>
147     </thead>
148     <tbody>
149 <?php
150
151     $res=sql(
"select lcase(m.memberID), g.name, DATE_FORMAT(m.signupDate, '" . makeSafe($adminConfig['MySQLDateFormat'], false) . "'), m.custom1, m.custom2, m.custom3, m.custom4, m.isBanned, m.isApproved from membership_users m left join membership_groups g on m.groupID=g.groupID $where order by m.signupDate limit $start, " . intval($adminConfig['membersPerPage']), $eo);
152     
while($row = db_fetch_row($res)){
153         $tr_class =
'';
154         
if($adminConfig['adminUsername'] == $row[0]) $tr_class = 'warning text-bold';
155         
if($adminConfig['anonymousMember'] == $row[0]) $tr_class = 'text-muted';
156         ?>
157         <tr
class="<?php echo $tr_class; ?>">
158             <?php
if($adminConfig['anonymousMember'] == $row[0]){ ?>
159                 <td
class="text-left"><?php echo thisOr($row[0]); ?></td>
160             <?php }
else{ ?>
161                 <td
class="text-left"><a href="pageEditMember.php?memberID=<?php echo $row[0]; ?>"><?php echo thisOr($row[0]); ?></a></td>
162             <?php } ?>
163             <td
class="text-left"><?php echo thisOr($row[1]); ?></td>
164             <td
class="text-left"><?php echo thisOr($row[2]); ?></td>
165             <td
class="text-left"><?php echo thisOr($row[3]); ?></td>
166             <td
class="text-left"><?php echo thisOr($row[4]); ?></td>
167             <td
class="text-left"><?php echo thisOr($row[5]); ?></td>
168             <td
class="text-left"><?php echo thisOr($row[6]); ?></td>
169             <td
class="text-left">
170                 <?php echo (($row[
7] && $row[8]) ? $Translation['Banned'] : ($row[8] ? $Translation['active'] : $Translation['waiting approval'] )); ?>
171             </td>
172             <td
class="text-center">
173                 <?php
if($adminConfig['anonymousMember'] == $row[0]){ ?>
174                     <i
class="glyphicon glyphicon-pencil text-muted"></i>
175                 <?php }
else{ ?>
176                     <a href=
"pageEditMember.php?memberID=<?php echo $row[0]; ?>"><i class="glyphicon glyphicon-pencil" title="<?php echo $Translation['Edit member'] ; ?>"></i></a>
177                 <?php } ?>
178
179                 <?php
if($adminConfig['anonymousMember'] == $row[0] || $adminConfig['adminUsername'] == $row[0]){ ?>
180                     <i
class="glyphicon glyphicon-trash text-muted"></i>
181                     <i
class="glyphicon glyphicon-ban-circle text-muted"></i>
182                 <?php }
else{ ?>
183                     <a href=
"pageDeleteMember.php?memberID=<?php echo $row[0]; ?>" onClick="return confirm('<?php echo str_replace ( '<USERNAME>' , $row[0] , $Translation['sure delete user'] ); ?>');"><i class="glyphicon glyphicon-trash text-danger" title="<?php echo $Translation['delete member'] ; ?>"></i></a>
184                     <?php
185                         
if(!$row[8]){ // if member is not approved, display approve link
186                             ?><a href=
"pageChangeMemberStatus.php?memberID=<?php echo $row[0]; ?>&approve=1"><i class="glyphicon glyphicon-ok text-success" title="<?php echo $Translation["unban this member"] ; ?>" title="<?php echo $Translation["approve this member"] ; ?>"></i></a><?php
187                         }
else{
188                             
if($row[7]){ // if member is banned, display unban link
189                                 ?><a href=
"pageChangeMemberStatus.php?memberID=<?php echo $row[0]; ?>&unban=1"><i class="glyphicon glyphicon-ok text-success" title="<?php echo $Translation["unban this member"] ; ?>"></i></a><?php
190                             }
else{ // if member is not banned, display ban link
191                                 ?><a href=
"pageChangeMemberStatus.php?memberID=<?php echo $row[0]; ?>&ban=1"><i class="glyphicon glyphicon-ban-circle text-danger" title="<?php echo $Translation["ban this member"] ; ?>"></i></a><?php
192                             }
193                         }
194                     ?>
195                 <?php } ?>
196
197                 <a href=
"pageViewRecords.php?memberID=<?php echo $row[0]; ?>"><i class="glyphicon glyphicon-th" title="<?php echo $Translation["View member records"] ; ?>"></i></a>
198
199                 <?php
if($adminConfig['anonymousMember'] == $row[0]){ ?>
200                     <i
class="glyphicon glyphicon-envelope text-muted"></i>
201                 <?php }
else{ ?>
202                     <a href=
"pageMail.php?memberID=<?php echo $row[0]; ?>"><i class="glyphicon glyphicon-envelope" title="<?php echo $Translation["send message to member"] ; ?>"></i></a>
203                 <?php } ?>
204             </td>
205         </tr>
206         <?php
207     }
208 ?>
209     </tbody>
210
211     <tfoot>
212         <tr>
213             <th colspan=
"9">
214                 <table width=
"100%" cellspacing="0">
215                     <tr>
216                         <td
class="text-left" width="33%">
217                             <a
class="btn btn-default" href="pageViewMembers.php?searchMembers=<?php echo $searchURL; ?>&groupID=<?php echo $groupID; ?>&status=<?php echo $status; ?>&searchField=<?php echo $searchField; ?>&page=<?php echo ($page>1 ? $page-1 : 1); ?>"><?php echo $Translation['previous'] ; ?></a>
218                         </td>
219                         <td
class="text-center" width="33%">
220                             <?php
221                                 $originalValues = array (
'<MEMBERNUM1>','<MEMBERNUM2>','<MEMBERS>' );
222                                 $replaceValues = array ( $start+
1 , $start+db_num_rows($res) , $numMembers );
223                                 echo str_replace ( $originalValues , $replaceValues , $Translation[
'displaying members'] );
224                             ?>
225                         </td>
226                         <td
class="text-right">
227                             <a
class="btn btn-default" href="pageViewMembers.php?searchMembers=<?php echo $searchURL; ?>&groupID=<?php echo $groupID; ?>&status=<?php echo $status; ?>&searchField=<?php echo $searchField; ?>&page=<?php echo ($page<ceil($numMembers/$adminConfig['membersPerPage']) ? $page+1 : ceil($numMembers/$adminConfig['membersPerPage'])); ?>"><?php echo $Translation['next'] ; ?></a>
228                         </td>
229                     </tr>
230                 </table>
231             </th>
232         </tr>
233         <tr>
234             <th colspan=
"9">
235                 <b><?php echo $Translation[
'key'] ; ?></b>
236                 <div
class="row">
237                     <div
class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-pencil text-info"></i> <?php echo $Translation['edit member details'] ; ?></div>
238                     <div
class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-trash text-danger"></i> <?php echo $Translation['delete member'] ; ?></div>
239                     <div
class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-ok text-success"></i> <?php echo $Translation['activate member'] ; ?></div>
240                     <div
class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-ban-circle text-danger"></i> <?php echo $Translation['ban member'] ; ?></div>
241                     <div
class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-th text-info"></i> <?php echo $Translation['view entered member records'] ; ?></div>
242                     <div
class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-envelope text-info"></i> <?php echo $Translation['send email to member'] ; ?></div>
243                 </div>
244             </th>
245         </tr>
246     </tfoot>
247 </table>
248
249 <style>
250     .form-inline .form-
group{ margin: .5em 1em; }
251 </style>
252
253 <script>
254     $j(function(){
255         $j(
'.form-inline select').addClass('form-control');
256     })
257 </script>
258
259
260 <?php
261     include(
"{$currDir}/incFooter.php");


Gõ tìm kiếm nhanh...